﻿using Microsoft.EntityFrameworkCore.Migrations;
using System;
using System.Collections.Generic;

namespace PhotoGallery.Migrations
{
    public partial class InitMigration : Migration
    {
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "Albums",
                columns: table => new
                {
                    Id = table.Column<string>(nullable: false),
                    AlbumPath = table.Column<string>(nullable: false),
                    AlbumType = table.Column<int>(nullable: false),
                    CoverPhoto = table.Column<string>(nullable: true),
                    CreateDate = table.Column<DateTime>(type: "datetime", nullable: false),
                    Description = table.Column<string>(nullable: true),
                    IsPublic = table.Column<bool>(type:"bool",nullable: false),
                    Name = table.Column<string>(nullable: true),
                    Owner = table.Column<string>(nullable: true),
                    Password = table.Column<string>(nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Albums", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "Photos",
                columns: table => new
                {
                    Hash = table.Column<string>(nullable: false),
                    AlbumName = table.Column<string>(nullable: false),
                    CDNUrl = table.Column<string>(nullable: true),
                    CDNUrl2 = table.Column<string>(nullable: true),
                    Description = table.Column<string>(nullable: true),
                    Name = table.Column<string>(nullable: false),
                    Path = table.Column<string>(nullable: false),
                    UploadClient = table.Column<int>(nullable: false),
                    UploadDate = table.Column<DateTime>(type: "datetime", nullable: false),
                    UploadUser = table.Column<string>(nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Photos", x => x.Hash);
                });

            migrationBuilder.CreateTable(
                name: "Users",
                columns: table => new
                {
                    UId = table.Column<int>(nullable: false)
                        .Annotation("Sqlite:Autoincrement", true),
                    CreateDate = table.Column<DateTime>(type: "datetime", nullable: false),
                    FailRetry = table.Column<int>(nullable: false),
                    IsEnable = table.Column<bool>(nullable: false),
                    LastLoginIP = table.Column<string>(nullable: true),
                    LastLoginTime = table.Column<DateTime>(type: "datetime", nullable: false),
                    Name = table.Column<string>(nullable: true),
                    PasswdHash = table.Column<string>(nullable: true),
                    Salt = table.Column<string>(nullable: true),
                    UserName = table.Column<string>(maxLength: 32, nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Users", x => x.UId);
                });

            migrationBuilder.CreateIndex(
                name: "IX_Albums_AlbumPath",
                table: "Albums",
                column: "AlbumPath");

            migrationBuilder.CreateIndex(
                name: "IX_Photos_AlbumName",
                table: "Photos",
                column: "AlbumName");
        }

        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "Albums");

            migrationBuilder.DropTable(
                name: "Photos");

            migrationBuilder.DropTable(
                name: "Users");
        }
    }
}
